package com.tepth.appmanageservice.protocol.bodys.login;

import com.tepth.appmanageservice.protocol.interfaces.ISend;
import com.tepth.appmanageservice.tools.ext.ExtToBytes;

public class ClientLogin implements ISend {
	private final short ID = 0x0F01;

	private byte type;
	private int clientId;
	private String password;
	private byte[] data;

	public short getID() {
		return ID;
	}

	public byte getType() {
		return this.type;
	}

	public int getClientId() {
		return this.clientId;
	}

	public String getPassword() {
		return this.password;
	}

	public ClientLogin() {
		this.clientId = com.tepth.appmanageservice.core.ClientInfo.ID;
		this.type = 1;
		this.password = com.tepth.appmanageservice.core.ClientInfo.PASSWORD;
	}

	@Override
	public short getId() {
		return ID;
	}

	@Override
	public short getLength() {
		return (short) this.data.length;
	}

	@Override
	public byte[] getResult() {
		return this.data;
	}

	@Override
	public void load() {
		byte[][] byteArray = new byte[3][];
		byteArray[0] = ExtToBytes.fromNumber(this.clientId);
		byteArray[1] = new byte[] { this.type };
		byteArray[2] = ExtToBytes.fromString16(this.password, " ");

		this.data = ExtToBytes.fromByteArray2(byteArray);
	}

	@Override
	public String toString() {
		return "ID：" + ID + "终端类型：" + this.type + "终端号：" + this.clientId + "密钥：" + this.password;
	}
}